﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.UpdateContinuousMfg.CCUiUCMUpdateContinuousMfgTCDlg
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using DnProcessSimulateCommands.CreateContinuousMFGFromCurve;
using System;
using System.ComponentModel;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands.UpdateContinuousMfg;

public class CCUiUCMUpdateContinuousMfgTCDlg : TxForm
{
  protected CApUCMUpdateContinuousMfgTCLogic _logic;
  protected ITxValidator _curveValidator;
  private IContainer components;
  protected TxObjEditBoxCtrl txebSourceCurve;
  protected Button btnOK;
  protected Button btnCancel;
  protected Label lbSetSourceCurve;

  public CCUiUCMUpdateContinuousMfgTCDlg()
  {
    this.InitializeComponent();
    this._curveValidator = (ITxValidator) new CApCMCCurvesValidator();
    this._logic = new CApUCMUpdateContinuousMfgTCLogic();
  }

  private void CCUiUCMUpdateContinuousMfgTCDlg_Load(object sender, EventArgs e)
  {
    ((Control) this).Text = string.Format(UCMStringTable.UCM_DialogTitle, (object) ((TxMfgFeature) this._logic.SelectedSeam).Name);
    this.SetSourceCurvePickProviders();
    this.SetSourceCurveValidators();
    this.txebSourceCurve.PickLevel = (TxPickLevel) 2;
    this.txebSourceCurve.ListenToPick = true;
    this.txebSourceCurve.Focus();
    this.EnableOrDisableAcceptButton();
  }

  private void btnCancel_Click(object sender, EventArgs e) => ((Form) this).Close();

  private void btnOK_Click(object sender, EventArgs e)
  {
    Cursor current = Cursor.Current;
    Cursor.Current = Cursors.WaitCursor;
    if (this._logic.ChangeCurve(this.txebSourceCurve.Object))
    {
      this._logic.UpdateChangesToRevision();
    }
    else
    {
      int num = (int) TxMessageBox.Show(UCMStringTable.ResourceManager.GetString("UMC_ChangeSourceCurveMessage"), UCMStringTable.ResourceManager.GetString("UMC_ErrorTitle"), MessageBoxButtons.OK, MessageBoxIcon.Hand);
    }
    this._logic.SelectTheSeamMfg();
    Cursor.Current = current;
    ((Form) this).Close();
  }

  private void SetSourceCurvePickProviders()
  {
    // ISSUE: unable to decompile the method.
  }

  private void SetSourceCurveValidators()
  {
    this.txebSourceCurve.SetValidator(this._curveValidator);
  }

  private void txcbSourceCurve_TypeInvalid(object sender, EventArgs e)
  {
    this.EnableOrDisableAcceptButton();
  }

  private void txcbSourceCurve_Picked(object sender, TxObjEditBoxCtrl_PickedEventArgs args)
  {
    this.EnableOrDisableAcceptButton();
  }

  private void txcbSourceCurve_TypeValid(object sender, EventArgs e)
  {
    this.EnableOrDisableAcceptButton();
  }

  private void EnableOrDisableAcceptButton()
  {
    this.btnOK.Enabled = this._logic.ShouldEnableOKButton(this.txebSourceCurve.Object);
    if (!this.btnOK.Enabled)
      return;
    this.btnOK.Focus();
  }

  protected virtual void Dispose(bool disposing)
  {
    if (disposing && this.components != null)
      this.components.Dispose();
    base.Dispose(disposing);
  }

  private void InitializeComponent()
  {
    ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof (CCUiUCMUpdateContinuousMfgTCDlg));
    this.txebSourceCurve = new TxObjEditBoxCtrl();
    this.btnOK = new Button();
    this.btnCancel = new Button();
    this.lbSetSourceCurve = new Label();
    ((Control) this).SuspendLayout();
    this.txebSourceCurve.KeepFaceEmphasizedWhenControlIsNotFocused = true;
    this.txebSourceCurve.ListenToPick = false;
    componentResourceManager.ApplyResources((object) this.txebSourceCurve, "txebSourceCurve");
    ((Control) this.txebSourceCurve).Name = "txebSourceCurve";
    this.txebSourceCurve.Object = (ITxObject) null;
    this.txebSourceCurve.PickAndClear = false;
    this.txebSourceCurve.PickLevel = (TxPickLevel) 1;
    this.txebSourceCurve.PickOnly = false;
    this.txebSourceCurve.ReadOnly = false;
    this.txebSourceCurve.ValidatorType = (TxValidatorType) 1;
    this.txebSourceCurve.TypeInvalid += new EventHandler(this.txcbSourceCurve_TypeInvalid);
    this.txebSourceCurve.TypeValid += new EventHandler(this.txcbSourceCurve_TypeValid);
    this.txebSourceCurve.Picked += new TxObjEditBoxCtrl_PickedEventHandler(this.txcbSourceCurve_Picked);
    componentResourceManager.ApplyResources((object) this.btnOK, "btnOK");
    this.btnOK.Name = "btnOK";
    this.btnOK.UseVisualStyleBackColor = true;
    this.btnOK.Click += new EventHandler(this.btnOK_Click);
    componentResourceManager.ApplyResources((object) this.btnCancel, "btnCancel");
    this.btnCancel.Name = "btnCancel";
    this.btnCancel.UseVisualStyleBackColor = true;
    this.btnCancel.Click += new EventHandler(this.btnCancel_Click);
    componentResourceManager.ApplyResources((object) this.lbSetSourceCurve, "lbSetSourceCurve");
    this.lbSetSourceCurve.Name = "lbSetSourceCurve";
    componentResourceManager.ApplyResources((object) this, "$this");
    ((ContainerControl) this).AutoScaleMode = AutoScaleMode.Font;
    ((Control) this).Controls.Add((Control) this.lbSetSourceCurve);
    ((Control) this).Controls.Add((Control) this.btnCancel);
    ((Control) this).Controls.Add((Control) this.btnOK);
    ((Control) this).Controls.Add((Control) this.txebSourceCurve);
    ((Form) this).FormBorderStyle = FormBorderStyle.FixedDialog;
    ((Form) this).MaximizeBox = false;
    ((Form) this).MinimizeBox = false;
    ((Control) this).Name = nameof (CCUiUCMUpdateContinuousMfgTCDlg);
    ((Form) this).Load += new EventHandler(this.CCUiUCMUpdateContinuousMfgTCDlg_Load);
    ((Control) this).ResumeLayout(false);
    ((Control) this).PerformLayout();
  }
}
